<template>
  <button
    class="button-drop"
    :class="{
      disabled: disabled || status === 'lock',
      light: status === 'light',
    }"
    @click="handleClick"
    :disabled="disabled"
  >
    <image
      class="button-drop-bg"
      :src="staticUrl('/static/images/button/drop.png')"
    />
    <view
      v-if="status === 'light'"
      class="button-drop-light"
      :class="{
        flash: flash,
      }"
    >
    </view>
    <view
      v-if="status === 'lock'"
      class="button-drop-lock"
    >
      <text class="iconfont icon-suo"> </text>
    </view>
    <view
      class="button-drop-text font-songti"
      :class="{
        dot: dot,
      }"
    >
      <slot></slot>
    </view>
  </button>
</template>

<script>
  export default {
    props: {
      type: {
        type: [String, Number],
        default: 0,
      },
      disabled: {
        type: Boolean,
        default: false,
      },

      status: {
        type: String,
        default: "lock", // lock light
      },

      flash: {
        type: Boolean,
        default: false,
      },

      dot: {
        type: Boolean,
        default: false,
      },
    },
    data() {
      return {};
    },
    mounted() {
      console.log("status", this.status);
    },
    methods: {
      handleClick() {
        this.$emit("click");
      },
    },
  };
</script>

<style lang="scss" scoped>
  //淡入淡出动画
  @keyframes fadeInOut {
    0% {
      opacity: 0;
    }
    100% {
      opacity: 1;
    }
  }

  .button {
    &-drop {
      position: relative;
      width: 56rpx !important;
      height: 200rpx !important;
      position: relative;
      background-color: transparent;
      border: none;
      outline: none;
      padding: 0;
      margin: 0;
      display: inline-flex;
      justify-content: center;
      align-items: center;
      overflow: unset !important;

      &::after {
        display: none;
      }
      &:active {
        background-color: transparent;
      }
      &-bg {
        position: relative;
        width: 56rpx !important;
        height: 200rpx !important;
        z-index: 1;
        image {
          width: 100% !important;
          height: 100% !important;
        }
      }

      &-text {
        position: absolute;
        top: 80rpx;
        z-index: 2;
        font-size: 24rpx;
        width: 24rpx;
        color: #ffffff;
        line-height: 1.4;
        //强制换行
        word-break: break-all;
        text-align: center;
        &.dot {
          &::after {
            content: "";
            display: block;
            width: 12rpx;
            height: 12rpx;
            background: #ff0000;
            border-radius: 50%;
            position: absolute;
            top: -18rpx;
            right: 0;

            border: 2rpx solid #fff;
          }
        }
      }
      &.disabled {
        .button-drop-bg {
          opacity: 0.5;
        }
      }

      &-light {
        position: absolute;
        z-index: 2;
        top: 20rpx;
        margin-left: 2rpx;
        background: #09ff00;
        width: 12rpx;
        height: 12rpx;
        display: flex;
        justify-content: center;
        align-items: center;
        border-radius: 50%;
        //循环播放 淡入淡出动画+
        &.flash {
          animation: fadeInOut 1s ease-in-out infinite alternate;
        }

        &::before {
          content: "";
          display: block;
          width: 22rpx;
          height: 22rpx;
          position: absolute;
          z-index: 2;
          border: 2rpx solid #09ff00;
          border-radius: 50%;
        }
        &::after {
          content: "";
          display: block;
          width: 34rpx;
          height: 34rpx;
          position: absolute;
          border: 4rpx solid rgba($color: #09ff00, $alpha: 0.5);
          border-radius: 50%;
        }
      }
      &.light {
        &::after {
          content: "";
          display: block;
          position: absolute;
          z-index: 0;
          top: 0;
          left: 0;
          right: 0;
          bottom: 0;
          background: rgba($color: #09ff00, $alpha: 0.2);
          filter: blur(40rpx);
        }
      }

      &-lock {
        position: absolute;
        z-index: 2;
        top: -15rpx;
        color: #ececd0;
      }
    }
  }
</style>
